package com.jk.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jk.dao.ServerBagDao;
import com.jk.dao.ServerBagTypeDao;
import com.jk.pojo.ServerBagEntity;
import com.jk.pojo.ServerBagTypeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ServerBagServer
 * @Description TODO
 * @Author Administrator
 * @Date 2022/10/19 9:57
 * @Version 1.0
 */
@Service
public class ServerBagServer {

    @Autowired
    private ServerBagDao serverBagDao;

    @Autowired
    private ServerBagTypeDao serverBagTypeDao;

    /**
     * @description: 查询
     * @author: tut
     * @date: 2022/10/19 15:21
     * @param: []
     * @return: java.util.List<com.jk.pojo.ServerBagEntity>
     *
     * @param serverBag*/
    public List<ServerBagEntity> findServerBag(ServerBagEntity serverBag) {
        QueryWrapper<ServerBagEntity> wrapper = new QueryWrapper<>();
        if (serverBag.getServer_grade()!=null ){
            wrapper.eq("server_grade", serverBag.getServer_grade());
        }
        if (serverBag.getServer_name()!="" && serverBag.getServer_name()!=null){
            wrapper.eq("server_name", serverBag.getServer_name());
        }

        List<ServerBagEntity> list = serverBagDao.selectList(wrapper);
        return list;

    }



    public List<ServerBagTypeEntity> getServerType() {
        QueryWrapper<ServerBagTypeEntity> wrapper = new QueryWrapper<>();
        List<ServerBagTypeEntity> list = serverBagTypeDao.selectList(wrapper);
        return list;
    }
}
